home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 7479 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.6 KB  |  58 lines

  1. Newsgroups: comp.lang.c++
  2. Path: natlab.research.philips.com!ijntema
  3. From: ijntema@natlab.research.philips.com (Hans IJntema)
  4. Subject: Re: what happens w/delete called twice ?
  5. Sender: news@natlab.research.philips.com (USENET News System)
  6. Message-ID: <ijntema.243.010270CF@natlab.research.philips.com>
  7. Date: Fri, 23 Feb 1996 14:25:29 GMT
  8. References:  <kcc.423.0EE12CF6@interaccess.com>
  9. Organization: Philips Research
  10. X-Newsreader: Trumpet for Windows [Version 1.0 Rev B]
  11.  
  12. In article <kcc.423.0EE12CF6@interaccess.com> kcc@interaccess.com (kcc) writes:
  13. >From: kcc@interaccess.com (kcc)
  14. >Subject: what happens w/delete called twice ?
  15. >Date: Thu, 22 Feb 1996 22:24:41
  16.  
  17. >Hello,
  18.  
  19. >        Can someone tell me... what happens when delete is called twice for the same 
  20. >memory deallocation ie.,
  21.  
  22. >        SOME_STRUCT     *struct_p       = new SOME STRUCT;
  23.  
  24. >        if ( foo_a() )
  25. >        {
  26. >                delete struct_p;
  27. >                retvalue = 0;
  28. >        }
  29. >        else
  30. >        {
  31. >                retvalue = foo_b();
  32. >        }
  33.  
  34. >        delete struct_p;
  35.  
  36. >        return( retvalue );
  37.  
  38.  
  39.  
  40. >Thanx !
  41. >kcc
  42.  
  43. Probably you will run into problems, which depends on OS, compiler etc.. 
  44. However, if you make the pointer NULL immediately after deleting, then 
  45. everything is fine because deleting a NULL pointer is allowed.
  46. ___________________________________________________________________________
  47. Hans IJntema
  48. Philips Research
  49. Building WO-02
  50. Prof. Holstlaan 4
  51. 5656 AA Eindhoven
  52. The Netherlands
  53.  
  54. e-mail: ijntema@natlab.research.philips.com
  55. Phone:  +31 40 2743325 or 2742877 
  56. Fax:    +31 40 2742630
  57. ___________________________________________________________________________
  58.